/*
 * Copyright © 2022-now 尛飛俠（Denvie） All rights reserved.
 */

package cn.denvie.springcloud.user.sentinel;

import cn.denvie.springcloud.user.domain.dto.UserDTO;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.extern.slf4j.Slf4j;

/**
 * UserSentinelHandler。
 *
 * @author Denvie
 * @date 2022/4/2
 * @since 1.0.0
 */
@Slf4j
public class UserSentinelHandler {
    /**
     * 限流处理。
     */
    public static UserDTO block(Long id, BlockException e) {
        log.error("block :: {}", e.getMessage());
        UserDTO userDTO = new UserDTO();
        userDTO.setId(id);
        userDTO.setUsername("block");
        userDTO.setNickname("限流用户");
        return userDTO;
    }
}
